<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="g" uri="http://geni-max.com/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title>卓越网络管理系统</title>
		<link rel="stylesheet" type="text/css" href="../css/public.css" />
		<script type="text/javascript" src="../js/ext-3.0.3/adapter/ext/ext-base.js" charset="UTF-8"></script>
		<script type="text/javascript" src="../js/ext-3.0.3/ext-all.js" charset="UTF-8"></script>
		<script type="text/javascript" src="../js/ext-3.0.3/source/locale/ext-lang-zh_CN.js" charset="UTF-8"></script>
	</head>
	<body>
		<table class="tab">
			<jsp:include page="base_info_gcblx.jsp" />
			<jsp:include page="base_info_kgsq.jsp" />
			<jsp:include page="base_info_kgpf.jsp" />
			<jsp:include page="base_info_cskgsq.jsp" />
			<jsp:include page="base_info_cskgpf.jsp" />
			<jsp:include page="base_info2.jsp" />
		</table>
		<form  method="post" onsubmit="return checkForm()" action="roomProject!process.action" style="margin-top:1px;" enctype="multipart/form-data">
			<input type="hidden" name="id" value="${roomProject.id}" />
			<input type="hidden" name="taskId" value="${taskId}" />
			<table class="tab" id="formTable">
				<tr>
					<td class="label" width="12%">GSM制式附件：</td>
					<td>
						<input type="file" id="attachmentFiles[0].file" size="40" name="attachmentFiles[0].file" />
						<input type="hidden" id="attachmentFiles[0].name" name="attachmentFiles[0].name" />
						<button type="button" onclick="addAttachment()">继续添加</button>
					</td>
				</tr>
				<tr>
					<td class="label">操作说明：</td>
					<td>
						<textarea rows="3" name="operateRemark"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="tcenter">
					<input type="hidden" id="actionName" name="actionName" value="开通GSM制式站点" />
						<button type="submit" onclick="document.getElementById('actionName').value = '开通GSM制式站点'">开通GSM制式站点</button>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
<script language="javascript">
var beginRow = 0;
var index = 1;
var count = 1;
function addAttachment() {
	var table = document.getElementById("formTable");
	var row = table.insertRow(beginRow + count);
	row.id = "atta_" + index;
	var td1 = row.insertCell();
	td1.className = "label";
	td1.innerHTML = "GSM制式附件：";
	var html = "<input type='file' id='attachmentFiles[" + index + "].file' size='40' name='attachmentFiles[" + index + "].file' />";
	html += "<input type='hidden' size='40' id='attachmentFiles[" + index + "].name' name='attachmentFiles[" + index + "].name' />";
	html += "<button type='button' onclick='addAttachment()'>继续添加</button>";
	html += "<button type='button' onclick='deleteAttachment(" + index + ")'>删除</button>";
	var td2 = row.insertCell();
	td2.innerHTML = html;
	index++;
	count++;
}
function deleteAttachment(rowId) {
	document.getElementById("formTable").deleteRow(beginRow + rowId - (index - count));
	count--;
}
function checkForm() {
	var unitName = "${task.previous.unitName}"
	for (i = 0; i < index; i++) {
		var file0 = document.getElementById("attachmentFiles[" + i + "].file");
		if (file0 != null && file0.value != "") {
			var fileNames = file0.value.replace(/\\/g, "/");
			fileNames = fileNames.split("/");
			document.getElementById("attachmentFiles[" + i + "].name").value = fileNames[fileNames.length - 1];
		}else{
			if(unitName == '网络部分制式审核'){
				return true;
			}else{
				alert("请上传GSM制式附件");
				return false;
			}
		}
	}
	return true;
}
function removeAtta(id) {
	if (confirm('确定要删除该附件吗？')) {
		Ext.Ajax.request({
			url: "roomProject!removeAttachment.action", 
			success: function() {
				document.getElementById("attact").removeChild(document.getElementById("atta" + id));
			},
			failure: function() {
				Ext.MessageBox.show({
					title: "提示",
					msg: "删除附件失败",
					buttons: Ext.Msg.OK,
					icon: Ext.MessageBox.ERROR
				});
			},
			params: {id: ${roomProject.id}, attachmentId: id}
		});
	}
}
</script>